/*
 * @Author: xmily
 * @Date: 2022-03-16 17:24:02
 * @LastEditors: xmily
 * @LastEditTime: 2022-03-22 22:05:42
 * @FilePath: \glxxapi\models\sitebaseinfo.js
 * @Description: 
 * 
 * Copyright (c) 2022 by xmily/mxthink.com.cn, All Rights Reserved. 
 */
var mongoose = require('../cfg/dbconfig.js')

var siteBaseInfoSchema=new mongoose.Schema({
    schoolname:String,
    term:String,
    classno:[
        {
            "classname":String,
            "sq":Number,
        }
    ],
    specialclass:[
        {
            "classname":String,
            "type":String,
            "megeclasses":[String],
            "sq":Number
        }
    ]
},{collection:'siteBaseInfo'})

siteBaseInfoSchema.statics.GetByQuery=async function(query,fields,sort){
    fields=fields||{};
    sort=sort||{_id:-1}
    let result= await this.find(query,fields).sort(sort).exec();
    return result
}
siteBaseInfoSchema.statics.myAggregate = async function (Pipeline) {
    let result = await this.aggregate(Pipeline).exec();
    return result;
  };

  //获取指定字段不重复的数据
  siteBaseInfoSchema.statics.getTerm=async function(field){
    field=field||"term";
    let result=await this.distinct(field).exec();
    return result;
}

module.exports = mongoose.model('siteBaseInfo', siteBaseInfoSchema)